package com.tuyrt.`as`.proj.kotlin_demo

import android.view.View
import java.util.*

/**
 * author: Administrator on 2021/5/20.
 * desc:
 */
fun main() {

    println("shop:${Shop().isClose}")
}

/**
 *  主构造方法
 */
class KotlinClass(name: String) {

    /**
     *  次构造1
     */
    constructor(view: View, name: String) : this(name) {
        println("name:$name")
    }

    /**
     *  次构造2
     */
    constructor(view: View, name: String, index: Int) : this(name) {
        println("name:$name")
    }
}

open class Animal(age: Int) {
    init {
        println(age)
    }

    open val foot: Int = 0

    open fun eat() {

    }
}

/**
 *  类，方法，变量 - 继承，覆写 需要父类 open
 */
class Dog(age: Int) : Animal(age) {

    override val foot = 4
    override fun eat() {

    }
}

/**--------------------属性-------------*/
class Shop {
    val name: String = "Android"
    val address: String? = null
    val isClose: Boolean
        get() = Calendar.getInstance().get(Calendar.HOUR_OF_DAY) > 11
    var score: Float = 0.0f
        get() = if (field < 0.2) 0.2f else field * 1.5f
        set(value) {
            println(value)
        }
}